In [15]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
import matplotlib.image as mpimg
from IPython.display import HTML, display
from scipy.ndimage import rotate
import random

# ------------------------------------------------
# Constants
# ------------------------------------------------
EARTH_MOON_DISTANCE = 384400  # in km

# ------------------------------------------------
# Mass calculation from marble count
# ------------------------------------------------
def compute_mass_from_marbles(n_marbles, m_per_marble=0.1, M_dry=1000.0):
    return M_dry + n_marbles * m_per_marble

# ------------------------------------------------
# [Simulation code remains unchanged]
# ------------------------------------------------
# (All simulate_full, ODEs, RK4, and animation code stays as-is)

# ------------------------------------------------
# Fun summary generator
# ------------------------------------------------
def generate_fun_summary(total_time_sec, n_marbles):
    days_alone = int(total_time_sec // (60 * 60 * 24))
    hours = int((total_time_sec % (60 * 60 * 24)) // 3600)

    fatigue_opts = [
        "Chill 🧘‍♂️",
        "Sweaty 💦",
        "Delirious 😵",
        "In a trance 🔮",
        "Running on dreams 🌈",
        "Throwing with rage 💢"
    ]

    hunger_opts = [
        "Mild Munchies 🍪",
        "Starving 🌌",
        "Ate the emergency cheese 🧀",
        "Dreaming of noodles 🍜",
        "Considering eating a marble 🤔",
        "Drank recycled tears 💧"
    ]

    friend_opts = [
        "Marble Henry",
        "Captain Pebble",
        "Sir Toss-a-lot",
        "Orb-Bob",
        "Commander Bounce",
        "The Great Sphere",
        "Smooth Steve"
    ]

    extra_lines = [
        "📦 Cargo: 14 snack bars, 1 diary, 900 regrets",
        "🎧 Soundtrack of the trip: Lo-fi space beats",
        "💬 Most said phrase: 'Just one more toss'",
        "🧼 Hygiene rating: 2/10 (smells like cosmic socks)",
        "🕳 Discovered black hole? Only emotionally",
        "📸 Last photo taken: blurry marble selfie",
        "🛠 Favourite tool: the emergency spoon"
    ]

    print("📋 MISSION REPORT")
    print(f"🕰 Days spent alone throwing marbles: {days_alone} days and {hours} hours")
    print(f"💤 Fatigue condition: {random.choice(fatigue_opts)}")
    print(f"🍽 Hunger status: {random.choice(hunger_opts)}")
    print(f"🪐 Current best friend: {random.choice(friend_opts)}")
    for line in random.sample(extra_lines, 2):
        print(line)

    
# ------------------------------------------------
# Main function
# ------------------------------------------------
if __name__ == "__main__":
    try:
        n_marbles = int(input("Enter number of marbles to throw: "))
        D = 384400000  # in metres
        dt = 1000
        R0 = 2.0
        beta = 0.05
        m = 0.1
        u = 50.0
        M_dry = 1000.0
        R_threshold = 0.5
        tau = 30.0

        M0 = compute_mass_from_marbles(n_marbles, m, M_dry)
        t_vals, x_vals, v_vals, a_vals, M_vals = simulate_full(D, dt, R0, beta, m, u, M0, M_dry, R_threshold, tau)

        total_time = t_vals[-1]
        final_distance_km = x_vals[-1] / 1000

        print(f"\nTotal time taken to get home: {total_time:.2f} seconds")
        display(animate_rocket(final_distance_km))
        generate_fun_summary(total_time, n_marbles)

    except ValueError:
        print("Please enter a valid number of marbles.")
Enter number of marbles to throw: 100000

Total time taken to get home: 8755000.00 seconds
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
/var/folders/tj/7r54fxys1hz9fglrqv43_4th0000gn/T/ipykernel_78847/3956098911.py:165: UserWarning: Glyph 128640 (\N{ROCKET}) missing from current font.
  ani = animation.FuncAnimation(fig, update, frames=100, blit=True, interval=30)
/var/folders/tj/7r54fxys1hz9fglrqv43_4th0000gn/T/ipykernel_78847/3956098911.py:165: UserWarning: Glyph 127756 (\N{MILKY WAY}) missing from current font.
  ani = animation.FuncAnimation(fig, update, frames=100, blit=True, interval=30)
/var/folders/tj/7r54fxys1hz9fglrqv43_4th0000gn/T/ipykernel_78847/3956098911.py:166: UserWarning: Glyph 128640 (\N{ROCKET}) missing from current font.
  animation_html = HTML(ani.to_jshtml())
/var/folders/tj/7r54fxys1hz9fglrqv43_4th0000gn/T/ipykernel_78847/3956098911.py:166: UserWarning: Glyph 127756 (\N{MILKY WAY}) missing from current font.
  animation_html = HTML(ani.to_jshtml())
🚀 You moved 384363.6 km!!
📋 MISSION REPORT
🕰 Days spent alone throwing marbles: 101 days and 7 hours
💤 Fatigue condition: Sweaty 💦
🍽 Hunger status: Considering eating a marble 🤔
🪐 Current best friend: Sir Toss-a-lot
📸 Last photo taken: blurry marble selfie
🕳 Discovered black hole? Only emotionally
In [ ]: